//
//  XZRuleCell.m
//  Teecloud
//
//  Created by PC on 2018/11/27.
//  Copyright © 2018年 小志. All rights reserved.
//

#import "XZRuleCell.h"
#import "SecItem.h"
#import "XZMemberList.h"
static NSString *const Noti_ScrollMove = @"Noti_ScrollMove";
@interface XZRuleCell ()<UICollectionViewDelegate,UICollectionViewDataSource>
@property (nonatomic,strong) UICollectionView *collectionView;
@property (nonatomic,assign) BOOL isNoti;

@end

@implementation XZRuleCell
- (void)setTitles:(NSArray *)titles{
    _titles = titles;
    [self.collectionView reloadData];
}
//- (void)setModel:(XZWorkTimeData *)model{
//    _model = model;
//    [self.collectionView reloadData];
//}
- (void)dealloc{
    XZLog(@"%s",__FUNCTION__);
    [[NSNotificationCenter defaultCenter]removeObserver:self];
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.isNoti = true;
        [self createView];
    }
    return self;
}

- (void)createView{
    
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    
    self.backgroundColor = k333333Color;
    
    CGFloat space = 1;
    CGFloat width = 100;
    
    self.label = [[UILabel alloc] init];
    self.label.textAlignment = NSTextAlignmentCenter;
    self.label.font = [UIFont systemFontOfSize:13];
    self.label.backgroundColor = kWhiteColor;
    
    self.label.adjustsFontSizeToFitWidth = true;
    [self.contentView addSubview:self.label];
    [self.label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(space);
        make.top.mas_equalTo(space / 2.0);
        make.bottom.mas_equalTo(-space / 2.0);
        make.width.mas_equalTo(80);
    }];
    
    UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
    layout.itemSize = CGSizeMake(width, SecCellHeight - space);
    layout.minimumLineSpacing = space;
    layout.minimumInteritemSpacing = space;
    layout.sectionInset = UIEdgeInsetsMake(space / 2.0, space, space / 2.0, space);
    
    layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
    
    self.collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
    self.collectionView.delegate = self;
    self.collectionView.dataSource = self;
    self.collectionView.backgroundColor = k333333Color;
    self.collectionView.showsVerticalScrollIndicator = false;
    self.collectionView.showsHorizontalScrollIndicator = false;
    [self.contentView addSubview:self.collectionView];
    [self.collectionView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.label.mas_right).offset(0);
        make.top.right.bottom.mas_equalTo(0);
    }];
    
    [self.collectionView registerClass:[SecItem class] forCellWithReuseIdentifier:@"SecItemID"];
    
    // 添加监听通知
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(scrollMove:) name:Noti_ScrollMove object:nil];
}

#pragma mark -- UICollectionViewDataSource
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
    return self.titles.count + 1;
}

- (UICollectionViewCell *)collectionView:(nonnull UICollectionView *)collectionView cellForItemAtIndexPath:(nonnull NSIndexPath *)indexPath {
    SecItem *item = [collectionView dequeueReusableCellWithReuseIdentifier:@"SecItemID" forIndexPath:indexPath];
    //把里面的控件全部移除掉
    [item.view.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
    if (self.label.tag == 100) {
        if (indexPath.row < self.titles.count) {
            UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
            [btn setTitle:self.titles[indexPath.row] forState:0];
            btn.titleLabel.font = [UIFont boldSystemFontOfSize:13.0f];
            btn.titleLabel.textAlignment = NSTextAlignmentCenter;
            [btn setTitleColor:k333333Color forState:0];
            [item.view addSubview:btn];
            [btn mas_makeConstraints:^(MASConstraintMaker *make) {
                make.edges.mas_equalTo(0);
            }];
        }
    }else{
        if (indexPath.row < self.titles.count) {
            if (indexPath.row == 0) {
                if (self.model.TimeData1 != nil) {
                    //都有的情况
                    if (!kIsEmptyString(self.model.TimeData1.ClockStatusName) && !kIsEmptyString(self.model.TimeData1.NamingStatusName)) {
                        UIButton *btn1 = [UIButton buttonWithType:UIButtonTypeCustom];
                        [btn1 setTitle:self.model.TimeData1.ClockStatusName forState:0];
                        btn1.titleLabel.font = [UIFont boldSystemFontOfSize:10.f];
                        btn1.titleLabel.textAlignment = NSTextAlignmentCenter;
                        [btn1 setBackgroundColor:kWhiteColor];
                        [item.view addSubview:btn1];
                        [btn1 mas_makeConstraints:^(MASConstraintMaker *make) {
                            make.left.mas_equalTo(12);
                            make.width.mas_equalTo(35);
                            make.height.mas_equalTo(25);
                            make.centerY.mas_equalTo(item.view);
                        }];
                        
                        if ([self.model.TimeData1.ClockStatusName isEqualToString:@"请假"]) {
                            [btn1 setTitleColor:kWhiteColor forState:UIControlStateNormal];
                            [btn1 setBackgroundColor:kFF8700Color];
                            //请假
                            btn1.tag = 1;
                            [btn1 addTarget:self action:@selector(btn1ApplyAction:) forControlEvents:UIControlEventTouchUpInside];
                            
                        }else if ([self.model.TimeData1.ClockStatusName isEqualToString:@"正常"]){
                            [btn1 setTitleColor:k1168E6Color forState:UIControlStateNormal];
                            btn1.layer.borderWidth = 0.5f;
                            btn1.layer.borderColor = k1168E6Color.CGColor;
                            
                        }else if ([self.model.TimeData1.ClockStatusName isEqualToString:@"缺卡"]){
                            [btn1 setTitleColor:kRedColor forState:UIControlStateNormal];
                            btn1.layer.borderWidth = 0.5f;
                            btn1.layer.borderColor = kRedColor.CGColor;
                        }else if ([self.model.TimeData1.ClockStatusName isEqualToString:@"迟到"] || [self.model.TimeData1.ClockStatusName isEqualToString:@"早退"]){
                            [btn1 setBackgroundColor:kWhiteColor];
                            [btn1 setTitleColor:kFF8700Color forState:UIControlStateNormal];
                            btn1.layer.borderWidth = 0.5f;
                            btn1.layer.borderColor = kFF8700Color.CGColor;
                        }
                        
                        UIButton *btn2 = [UIButton buttonWithType:UIButtonTypeCustom];
                        [btn2 setTitle:self.model.TimeData1.NamingStatusName forState:0];
                        btn2.titleLabel.font = [UIFont boldSystemFontOfSize:10.f];
                        btn2.titleLabel.textAlignment = NSTextAlignmentCenter;
                        [btn2 setBackgroundColor:kWhiteColor];
                        [item.view addSubview:btn2];
                        [btn2 mas_makeConstraints:^(MASConstraintMaker *make) {
                            make.right.mas_equalTo(-12);
                            make.width.mas_equalTo(35);
                            make.height.mas_equalTo(25);
                            make.centerY.mas_equalTo(item.view);
                        }];
                        if ([self.model.TimeData1.NamingStatusName isEqualToString:@"请假"]) {
                            [btn2 setTitleColor:kFF8700Color forState:UIControlStateNormal];
                            btn2.layer.borderWidth = 0.5f;
                            btn2.layer.borderColor = kFF8700Color.CGColor;
                        }else if ([self.model.TimeData1.NamingStatusName isEqualToString:@"已到"]){
                            [btn2 setTitleColor:k1168E6Color forState:UIControlStateNormal];
                            btn2.layer.borderWidth = 0.5f;
                            btn2.layer.borderColor = k1168E6Color.CGColor;
                            
                        }else if ([self.model.TimeData1.NamingStatusName isEqualToString:@"未到"]){
                            [btn2 setTitleColor:kRedColor forState:UIControlStateNormal];
                            btn2.layer.borderWidth = 0.5f;
                            btn2.layer.borderColor = kRedColor.CGColor;
                            
                        }
                    }
                    
                    //有ClockStatusName NamingStatusName没有
                    if (!kIsEmptyString(self.model.TimeData1.ClockStatusName) && kIsEmptyString(self.model.TimeData1.NamingStatusName)) {
                        
                        UIButton *btn1 = [UIButton buttonWithType:UIButtonTypeCustom];
                        [btn1 setTitle:self.model.TimeData1.ClockStatusName forState:0];
                        btn1.titleLabel.font = [UIFont boldSystemFontOfSize:10.f];
                        btn1.titleLabel.textAlignment = NSTextAlignmentCenter;
                        [btn1 setBackgroundColor:kWhiteColor];
                        [item.view addSubview:btn1];
                        [btn1 mas_makeConstraints:^(MASConstraintMaker *make) {
                            make.width.mas_equalTo(35);
                            make.height.mas_equalTo(25);
                            make.center.mas_equalTo(item.view);
                        }];
                        
                        if ([self.model.TimeData1.ClockStatusName isEqualToString:@"请假"]) {
                            [btn1 setTitleColor:kWhiteColor forState:UIControlStateNormal];
                            [btn1 setBackgroundColor:kFF8700Color];
                            //请假
                            btn1.tag = 1;
                            [btn1 addTarget:self action:@selector(btn1ApplyAction:) forControlEvents:UIControlEventTouchUpInside];
                        }else if ([self.model.TimeData1.ClockStatusName isEqualToString:@"正常"]){
                            [btn1 setTitleColor:k1168E6Color forState:UIControlStateNormal];
                            btn1.layer.borderWidth = 0.5f;
                            btn1.layer.borderColor = k1168E6Color.CGColor;
                            
                        }else if ([self.model.TimeData1.ClockStatusName isEqualToString:@"缺卡"]){
                            [btn1 setTitleColor:kRedColor forState:UIControlStateNormal];
                            btn1.layer.borderWidth = 0.5f;
                            btn1.layer.borderColor = kRedColor.CGColor;
                        }else if ([self.model.TimeData1.ClockStatusName isEqualToString:@"迟到"] || [self.model.TimeData1.ClockStatusName isEqualToString:@"早退"]){
                            [btn1 setBackgroundColor:kWhiteColor];
                            [btn1 setTitleColor:kFF8700Color forState:UIControlStateNormal];
                            btn1.layer.borderWidth = 0.5f;
                            btn1.layer.borderColor = kFF8700Color.CGColor;
                        }
                        
                    }
                    
                    //没有ClockStatusName NamingStatusName有
                    if (kIsEmptyString(self.model.TimeData1.ClockStatusName) && !kIsEmptyString(self.model.TimeData1.NamingStatusName)) {
                        UIButton *btn2 = [UIButton buttonWithType:UIButtonTypeCustom];
                        [btn2 setTitle:self.model.TimeData1.NamingStatusName forState:0];
                        btn2.titleLabel.font = [UIFont boldSystemFontOfSize:10.f];
                        btn2.titleLabel.textAlignment = NSTextAlignmentCenter;
                        [btn2 setBackgroundColor:kWhiteColor];
                        [item.view addSubview:btn2];
                        [btn2 mas_makeConstraints:^(MASConstraintMaker *make) {
                            make.width.mas_equalTo(35);
                            make.height.mas_equalTo(25);
                            make.center.mas_equalTo(item.view);
                        }];
                        if ([self.model.TimeData1.NamingStatusName isEqualToString:@"请假"]) {
                            [btn2 setTitleColor:kFF8700Color forState:UIControlStateNormal];
                            btn2.layer.borderWidth = 0.5f;
                            btn2.layer.borderColor = kFF8700Color.CGColor;
                        }else if ([self.model.TimeData1.NamingStatusName isEqualToString:@"已到"]){
                            [btn2 setTitleColor:k1168E6Color forState:UIControlStateNormal];
                            btn2.layer.borderWidth = 0.5f;
                            btn2.layer.borderColor = k1168E6Color.CGColor;
                            
                        }else if ([self.model.TimeData1.NamingStatusName isEqualToString:@"未到"]){
                            [btn2 setTitleColor:kRedColor forState:UIControlStateNormal];
                            btn2.layer.borderWidth = 0.5f;
                            btn2.layer.borderColor = kRedColor.CGColor;
                            
                        }
                        
                    }
                }
            }
            
           
            //row=1
            if (indexPath.row == 1) {
                if (self.model.TimeData2 != nil) {
                    //都有的情况
                    if (!kIsEmptyString(self.model.TimeData2.ClockStatusName) && !kIsEmptyString(self.model.TimeData2.NamingStatusName)) {
                        UIButton *btn1 = [UIButton buttonWithType:UIButtonTypeCustom];
                        [btn1 setTitle:self.model.TimeData2.ClockStatusName forState:0];
                        btn1.titleLabel.font = [UIFont boldSystemFontOfSize:10.f];
                        btn1.titleLabel.textAlignment = NSTextAlignmentCenter;
                        [btn1 setBackgroundColor:kWhiteColor];
                        [item.view addSubview:btn1];
                        [btn1 mas_makeConstraints:^(MASConstraintMaker *make) {
                            make.left.mas_equalTo(12);
                            make.width.mas_equalTo(35);
                            make.height.mas_equalTo(25);
                            make.centerY.mas_equalTo(item.view);
                        }];
                        
                        if ([self.model.TimeData2.ClockStatusName isEqualToString:@"请假"]) {
                            [btn1 setTitleColor:kWhiteColor forState:UIControlStateNormal];
                            [btn1 setBackgroundColor:kFF8700Color];
                            //请假
                            btn1.tag = 2;
                            [btn1 addTarget:self action:@selector(btn1ApplyAction:) forControlEvents:UIControlEventTouchUpInside];
                        }else if ([self.model.TimeData2.ClockStatusName isEqualToString:@"正常"]){
                            [btn1 setTitleColor:k1168E6Color forState:UIControlStateNormal];
                            btn1.layer.borderWidth = 0.5f;
                            btn1.layer.borderColor = k1168E6Color.CGColor;
                            
                        }else if ([self.model.TimeData2.ClockStatusName isEqualToString:@"缺卡"]){
                            [btn1 setTitleColor:kRedColor forState:UIControlStateNormal];
                            btn1.layer.borderWidth = 0.5f;
                            btn1.layer.borderColor = kRedColor.CGColor;
                        }else if ([self.model.TimeData2.ClockStatusName isEqualToString:@"迟到"] || [self.model.TimeData2.ClockStatusName isEqualToString:@"早退"]){
                            [btn1 setBackgroundColor:kWhiteColor];
                            [btn1 setTitleColor:kFF8700Color forState:UIControlStateNormal];
                            btn1.layer.borderWidth = 0.5f;
                            btn1.layer.borderColor = kFF8700Color.CGColor;
                        }
                        
                        UIButton *btn2 = [UIButton buttonWithType:UIButtonTypeCustom];
                        [btn2 setTitle:self.model.TimeData2.NamingStatusName forState:0];
                        btn2.titleLabel.font = [UIFont boldSystemFontOfSize:10.f];
                        btn2.titleLabel.textAlignment = NSTextAlignmentCenter;
                        [btn2 setBackgroundColor:kWhiteColor];
                        [item.view addSubview:btn2];
                        [btn2 mas_makeConstraints:^(MASConstraintMaker *make) {
                            make.right.mas_equalTo(-12);
                            make.width.mas_equalTo(35);
                            make.height.mas_equalTo(25);
                            make.centerY.mas_equalTo(item.view);
                        }];
                        if ([self.model.TimeData2.NamingStatusName isEqualToString:@"请假"]) {
                            [btn2 setTitleColor:kFF8700Color forState:UIControlStateNormal];
                            btn2.layer.borderWidth = 0.5f;
                            btn2.layer.borderColor = kFF8700Color.CGColor;
                        }else if ([self.model.TimeData2.NamingStatusName isEqualToString:@"已到"]){
                            [btn2 setTitleColor:k1168E6Color forState:UIControlStateNormal];
                            btn2.layer.borderWidth = 0.5f;
                            btn2.layer.borderColor = k1168E6Color.CGColor;
                            
                        }else if ([self.model.TimeData2.NamingStatusName isEqualToString:@"未到"]){
                            [btn2 setTitleColor:kRedColor forState:UIControlStateNormal];
                            btn2.layer.borderWidth = 0.5f;
                            btn2.layer.borderColor = kRedColor.CGColor;
                            
                        }
                    }
                    
                    //有ClockStatusName NamingStatusName没有
                    if (!kIsEmptyString(self.model.TimeData2.ClockStatusName) && kIsEmptyString(self.model.TimeData2.NamingStatusName)) {
                        
                        UIButton *btn1 = [UIButton buttonWithType:UIButtonTypeCustom];
                        [btn1 setTitle:self.model.TimeData2.ClockStatusName forState:0];
                        btn1.titleLabel.font = [UIFont boldSystemFontOfSize:10.f];
                        btn1.titleLabel.textAlignment = NSTextAlignmentCenter;
                        [btn1 setBackgroundColor:kWhiteColor];
                        [item.view addSubview:btn1];
                        [btn1 mas_makeConstraints:^(MASConstraintMaker *make) {
                            make.width.mas_equalTo(35);
                            make.height.mas_equalTo(25);
                            make.center.mas_equalTo(item.view);
                        }];
                        
                        if ([self.model.TimeData2.ClockStatusName isEqualToString:@"请假"]) {
                            [btn1 setTitleColor:kWhiteColor forState:UIControlStateNormal];
                            [btn1 setBackgroundColor:kFF8700Color];
                            //请假
                            btn1.tag = 2;
                            [btn1 addTarget:self action:@selector(btn1ApplyAction:) forControlEvents:UIControlEventTouchUpInside];
                        }else if ([self.model.TimeData2.ClockStatusName isEqualToString:@"正常"]){
                            [btn1 setTitleColor:k1168E6Color forState:UIControlStateNormal];
                            btn1.layer.borderWidth = 0.5f;
                            btn1.layer.borderColor = k1168E6Color.CGColor;
                            
                        }else if ([self.model.TimeData2.ClockStatusName isEqualToString:@"缺卡"]){
                            [btn1 setTitleColor:kRedColor forState:UIControlStateNormal];
                            btn1.layer.borderWidth = 0.5f;
                            btn1.layer.borderColor = kRedColor.CGColor;
                        }else if ([self.model.TimeData2.ClockStatusName isEqualToString:@"迟到"] || [self.model.TimeData2.ClockStatusName isEqualToString:@"早退"]){
                            [btn1 setBackgroundColor:kWhiteColor];
                            [btn1 setTitleColor:kFF8700Color forState:UIControlStateNormal];
                            btn1.layer.borderWidth = 0.5f;
                            btn1.layer.borderColor = kFF8700Color.CGColor;
                        }
                        
                    }
                    
                    //没有ClockStatusName NamingStatusName有
                    if (kIsEmptyString(self.model.TimeData2.ClockStatusName) && !kIsEmptyString(self.model.TimeData2.NamingStatusName)) {
                        UIButton *btn2 = [UIButton buttonWithType:UIButtonTypeCustom];
                        [btn2 setTitle:self.model.TimeData2.NamingStatusName forState:0];
                        btn2.titleLabel.font = [UIFont boldSystemFontOfSize:10.f];
                        btn2.titleLabel.textAlignment = NSTextAlignmentCenter;
                        [btn2 setBackgroundColor:kWhiteColor];
                        [item.view addSubview:btn2];
                        [btn2 mas_makeConstraints:^(MASConstraintMaker *make) {
                            make.width.mas_equalTo(35);
                            make.height.mas_equalTo(25);
                            make.center.mas_equalTo(item.view);
                        }];
                        if ([self.model.TimeData2.NamingStatusName isEqualToString:@"请假"]) {
                            [btn2 setTitleColor:kFF8700Color forState:UIControlStateNormal];
                            btn2.layer.borderWidth = 0.5f;
                            btn2.layer.borderColor = kFF8700Color.CGColor;
                        }else if ([self.model.TimeData2.NamingStatusName isEqualToString:@"已到"]){
                            [btn2 setTitleColor:k1168E6Color forState:UIControlStateNormal];
                            btn2.layer.borderWidth = 0.5f;
                            btn2.layer.borderColor = k1168E6Color.CGColor;
                            
                        }else if ([self.model.TimeData2.NamingStatusName isEqualToString:@"未到"]){
                            [btn2 setTitleColor:kRedColor forState:UIControlStateNormal];
                            btn2.layer.borderWidth = 0.5f;
                            btn2.layer.borderColor = kRedColor.CGColor;
                            
                        }
                        
                    }
                }
            }
            
            //row=2
            if (indexPath.row == 2) {
                if (self.model.TimeData3 != nil) {
                    //都有的情况
                    if (!kIsEmptyString(self.model.TimeData3.ClockStatusName) && !kIsEmptyString(self.model.TimeData3.NamingStatusName)) {
                        UIButton *btn1 = [UIButton buttonWithType:UIButtonTypeCustom];
                        [btn1 setTitle:self.model.TimeData3.ClockStatusName forState:0];
                        btn1.titleLabel.font = [UIFont boldSystemFontOfSize:10.f];
                        btn1.titleLabel.textAlignment = NSTextAlignmentCenter;
                        [btn1 setBackgroundColor:kWhiteColor];
                        [item.view addSubview:btn1];
                        [btn1 mas_makeConstraints:^(MASConstraintMaker *make) {
                            make.left.mas_equalTo(12);
                            make.width.mas_equalTo(35);
                            make.height.mas_equalTo(25);
                            make.centerY.mas_equalTo(item.view);
                        }];
                        
                        if ([self.model.TimeData3.ClockStatusName isEqualToString:@"请假"]) {
                            [btn1 setTitleColor:kWhiteColor forState:UIControlStateNormal];
                            [btn1 setBackgroundColor:kFF8700Color];
                            //请假
                            btn1.tag = 3;
                            [btn1 addTarget:self action:@selector(btn1ApplyAction:) forControlEvents:UIControlEventTouchUpInside];
                        }else if ([self.model.TimeData3.ClockStatusName isEqualToString:@"正常"]){
                            [btn1 setTitleColor:k1168E6Color forState:UIControlStateNormal];
                            btn1.layer.borderWidth = 0.5f;
                            btn1.layer.borderColor = k1168E6Color.CGColor;
                            
                        }else if ([self.model.TimeData3.ClockStatusName isEqualToString:@"缺卡"]){
                            [btn1 setTitleColor:kRedColor forState:UIControlStateNormal];
                            btn1.layer.borderWidth = 0.5f;
                            btn1.layer.borderColor = kRedColor.CGColor;
                        }else if ([self.model.TimeData3.ClockStatusName isEqualToString:@"迟到"] || [self.model.TimeData3.ClockStatusName isEqualToString:@"早退"]){
                            [btn1 setTitleColor:kFF8700Color forState:UIControlStateNormal];
                            btn1.layer.borderWidth = 0.5f;
                            btn1.layer.borderColor = kFF8700Color.CGColor;
                        }
                        
                        UIButton *btn2 = [UIButton buttonWithType:UIButtonTypeCustom];
                        [btn2 setTitle:self.model.TimeData3.NamingStatusName forState:0];
                        btn2.titleLabel.font = [UIFont boldSystemFontOfSize:10.f];
                        btn2.titleLabel.textAlignment = NSTextAlignmentCenter;
                        [btn2 setBackgroundColor:kWhiteColor];
                        [item.view addSubview:btn2];
                        [btn2 mas_makeConstraints:^(MASConstraintMaker *make) {
                            make.right.mas_equalTo(-12);
                            make.width.mas_equalTo(35);
                            make.height.mas_equalTo(25);
                            make.centerY.mas_equalTo(item.view);
                        }];
                        if ([self.model.TimeData3.NamingStatusName isEqualToString:@"请假"]) {
                            [btn2 setTitleColor:kFF8700Color forState:UIControlStateNormal];
                            btn2.layer.borderWidth = 0.5f;
                            btn2.layer.borderColor = kFF8700Color.CGColor;
                        }else if ([self.model.TimeData3.NamingStatusName isEqualToString:@"已到"]){
                            [btn2 setTitleColor:k1168E6Color forState:UIControlStateNormal];
                            btn2.layer.borderWidth = 0.5f;
                            btn2.layer.borderColor = k1168E6Color.CGColor;
                            
                        }else if ([self.model.TimeData3.NamingStatusName isEqualToString:@"未到"]){
                            [btn2 setTitleColor:kRedColor forState:UIControlStateNormal];
                            btn2.layer.borderWidth = 0.5f;
                            btn2.layer.borderColor = kRedColor.CGColor;
                            
                        }
                    }
                    
                    //有ClockStatusName NamingStatusName没有
                    if (!kIsEmptyString(self.model.TimeData3.ClockStatusName) && kIsEmptyString(self.model.TimeData3.NamingStatusName)) {
                        
                        UIButton *btn1 = [UIButton buttonWithType:UIButtonTypeCustom];
                        [btn1 setTitle:self.model.TimeData3.ClockStatusName forState:0];
                        btn1.titleLabel.font = [UIFont boldSystemFontOfSize:10.f];
                        btn1.titleLabel.textAlignment = NSTextAlignmentCenter;
                        [btn1 setBackgroundColor:kWhiteColor];
                        [item.view addSubview:btn1];
                        [btn1 mas_makeConstraints:^(MASConstraintMaker *make) {
                            make.width.mas_equalTo(35);
                            make.height.mas_equalTo(25);
                            make.center.mas_equalTo(item.view);
                        }];
                        
                        if ([self.model.TimeData3.ClockStatusName isEqualToString:@"请假"]) {
                            [btn1 setTitleColor:kWhiteColor forState:UIControlStateNormal];
                            [btn1 setBackgroundColor:kFF8700Color];
                            //请假
                            btn1.tag = 3;
                            [btn1 addTarget:self action:@selector(btn1ApplyAction:) forControlEvents:UIControlEventTouchUpInside];
                        }else if ([self.model.TimeData3.ClockStatusName isEqualToString:@"正常"]){
                            [btn1 setTitleColor:k1168E6Color forState:UIControlStateNormal];
                            btn1.layer.borderWidth = 0.5f;
                            btn1.layer.borderColor = k1168E6Color.CGColor;
                            
                        }else if ([self.model.TimeData3.ClockStatusName isEqualToString:@"缺卡"]){
                            [btn1 setTitleColor:kRedColor forState:UIControlStateNormal];
                            btn1.layer.borderWidth = 0.5f;
                            btn1.layer.borderColor = kRedColor.CGColor;
                        }else if ([self.model.TimeData3.ClockStatusName isEqualToString:@"迟到"] || [self.model.TimeData3.ClockStatusName isEqualToString:@"早退"]){
                            [btn1 setTitleColor:kFF8700Color forState:UIControlStateNormal];
                            btn1.layer.borderWidth = 0.5f;
                            btn1.layer.borderColor = kFF8700Color.CGColor;
                        }
                        
                    }
                    
                    //没有ClockStatusName NamingStatusName有
                    if (kIsEmptyString(self.model.TimeData3.ClockStatusName) && !kIsEmptyString(self.model.TimeData3.NamingStatusName)) {
                        UIButton *btn2 = [UIButton buttonWithType:UIButtonTypeCustom];
                        [btn2 setTitle:self.model.TimeData3.NamingStatusName forState:0];
                        btn2.titleLabel.font = [UIFont boldSystemFontOfSize:10.f];
                        btn2.titleLabel.textAlignment = NSTextAlignmentCenter;
                        [btn2 setBackgroundColor:kWhiteColor];
                        [item.view addSubview:btn2];
                        [btn2 mas_makeConstraints:^(MASConstraintMaker *make) {
                            make.width.mas_equalTo(35);
                            make.height.mas_equalTo(25);
                            make.center.mas_equalTo(item.view);
                        }];
                        if ([self.model.TimeData3.NamingStatusName isEqualToString:@"请假"]) {
                            [btn2 setTitleColor:kFF8700Color forState:UIControlStateNormal];
                            btn2.layer.borderWidth = 0.5f;
                            btn2.layer.borderColor = kFF8700Color.CGColor;
                        }else if ([self.model.TimeData3.NamingStatusName isEqualToString:@"已到"]){
                            [btn2 setTitleColor:k1168E6Color forState:UIControlStateNormal];
                            btn2.layer.borderWidth = 0.5f;
                            btn2.layer.borderColor = k1168E6Color.CGColor;
                            
                        }else if ([self.model.TimeData3.NamingStatusName isEqualToString:@"未到"]){
                            [btn2 setTitleColor:kRedColor forState:UIControlStateNormal];
                            btn2.layer.borderWidth = 0.5f;
                            btn2.layer.borderColor = kRedColor.CGColor;
                            
                        }
                        
                    }
                }
            }
            
            //row=3
            if (indexPath.row == 3) {
                if (self.model.TimeData4 != nil) {
                    //都有的情况
                    if (!kIsEmptyString(self.model.TimeData4.ClockStatusName) && !kIsEmptyString(self.model.TimeData4.NamingStatusName)) {
                        UIButton *btn1 = [UIButton buttonWithType:UIButtonTypeCustom];
                        [btn1 setTitle:self.model.TimeData4.ClockStatusName forState:0];
                        btn1.titleLabel.font = [UIFont boldSystemFontOfSize:10.f];
                        btn1.titleLabel.textAlignment = NSTextAlignmentCenter;
                        [btn1 setBackgroundColor:kWhiteColor];
                        [item.view addSubview:btn1];
                        [btn1 mas_makeConstraints:^(MASConstraintMaker *make) {
                            make.left.mas_equalTo(12);
                            make.width.mas_equalTo(35);
                            make.height.mas_equalTo(25);
                            make.centerY.mas_equalTo(item.view);
                        }];
                        
                        if ([self.model.TimeData4.ClockStatusName isEqualToString:@"请假"]) {
                            [btn1 setTitleColor:kWhiteColor forState:UIControlStateNormal];
                            [btn1 setBackgroundColor:kFF8700Color];
                            //请假
                            btn1.tag = 4;
                            [btn1 addTarget:self action:@selector(btn1ApplyAction:) forControlEvents:UIControlEventTouchUpInside];
                        }else if ([self.model.TimeData4.ClockStatusName isEqualToString:@"正常"]){
                            [btn1 setTitleColor:k1168E6Color forState:UIControlStateNormal];
                            btn1.layer.borderWidth = 0.5f;
                            btn1.layer.borderColor = k1168E6Color.CGColor;
                            
                        }else if ([self.model.TimeData4.ClockStatusName isEqualToString:@"缺卡"]){
                            [btn1 setTitleColor:kRedColor forState:UIControlStateNormal];
                            btn1.layer.borderWidth = 0.5f;
                            btn1.layer.borderColor = kRedColor.CGColor;
                        }else if ([self.model.TimeData4.ClockStatusName isEqualToString:@"迟到"] || [self.model.TimeData4.ClockStatusName isEqualToString:@"早退"]){
                            [btn1 setTitleColor:kFF8700Color forState:UIControlStateNormal];
                            btn1.layer.borderWidth = 0.5f;
                            btn1.layer.borderColor = kFF8700Color.CGColor;
                        }
                        
                        UIButton *btn2 = [UIButton buttonWithType:UIButtonTypeCustom];
                        [btn2 setTitle:self.model.TimeData4.NamingStatusName forState:0];
                        btn2.titleLabel.font = [UIFont boldSystemFontOfSize:10.f];
                        btn2.titleLabel.textAlignment = NSTextAlignmentCenter;
                        [btn2 setBackgroundColor:kWhiteColor];
                        [item.view addSubview:btn2];
                        [btn2 mas_makeConstraints:^(MASConstraintMaker *make) {
                            make.right.mas_equalTo(-12);
                            make.width.mas_equalTo(35);
                            make.height.mas_equalTo(25);
                            make.centerY.mas_equalTo(item.view);
                        }];
                        if ([self.model.TimeData4.NamingStatusName isEqualToString:@"请假"]) {
                            [btn2 setTitleColor:kFF8700Color forState:UIControlStateNormal];
                            btn2.layer.borderWidth = 0.5f;
                            btn2.layer.borderColor = kFF8700Color.CGColor;
                        }else if ([self.model.TimeData4.NamingStatusName isEqualToString:@"已到"]){
                            [btn2 setTitleColor:k1168E6Color forState:UIControlStateNormal];
                            btn2.layer.borderWidth = 0.5f;
                            btn2.layer.borderColor = k1168E6Color.CGColor;
                            
                        }else if ([self.model.TimeData4.NamingStatusName isEqualToString:@"未到"]){
                            [btn2 setTitleColor:kRedColor forState:UIControlStateNormal];
                            btn2.layer.borderWidth = 0.5f;
                            btn2.layer.borderColor = kRedColor.CGColor;
                            
                        }
                    }
                    
                    //有ClockStatusName NamingStatusName没有
                    if (!kIsEmptyString(self.model.TimeData4.ClockStatusName) && kIsEmptyString(self.model.TimeData4.NamingStatusName)) {
                        
                        UIButton *btn1 = [UIButton buttonWithType:UIButtonTypeCustom];
                        [btn1 setTitle:self.model.TimeData4.ClockStatusName forState:0];
                        btn1.titleLabel.font = [UIFont boldSystemFontOfSize:10.f];
                        btn1.titleLabel.textAlignment = NSTextAlignmentCenter;
                        [btn1 setBackgroundColor:kWhiteColor];
                        [item.view addSubview:btn1];
                        [btn1 mas_makeConstraints:^(MASConstraintMaker *make) {
                            make.width.mas_equalTo(35);
                            make.height.mas_equalTo(25);
                            make.center.mas_equalTo(item.view);
                        }];
                        
                        if ([self.model.TimeData4.ClockStatusName isEqualToString:@"请假"]) {
                            [btn1 setTitleColor:kWhiteColor forState:UIControlStateNormal];
                            [btn1 setBackgroundColor:kFF8700Color];
                            //请假
                            btn1.tag = 4;
                            [btn1 addTarget:self action:@selector(btn1ApplyAction:) forControlEvents:UIControlEventTouchUpInside];
                        }else if ([self.model.TimeData4.ClockStatusName isEqualToString:@"正常"]){
                            [btn1 setTitleColor:k1168E6Color forState:UIControlStateNormal];
                            btn1.layer.borderWidth = 0.5f;
                            btn1.layer.borderColor = k1168E6Color.CGColor;
                            
                        }else if ([self.model.TimeData4.ClockStatusName isEqualToString:@"缺卡"]){
                            [btn1 setTitleColor:kRedColor forState:UIControlStateNormal];
                            btn1.layer.borderWidth = 0.5f;
                            btn1.layer.borderColor = kRedColor.CGColor;
                        }else if ([self.model.TimeData4.ClockStatusName isEqualToString:@"迟到"] || [self.model.TimeData4.ClockStatusName isEqualToString:@"早退"]){
                            [btn1 setTitleColor:kFF8700Color forState:UIControlStateNormal];
                            btn1.layer.borderWidth = 0.5f;
                            btn1.layer.borderColor = kFF8700Color.CGColor;
                        }
                        
                    }
                    
                    //没有ClockStatusName NamingStatusName有
                    if (kIsEmptyString(self.model.TimeData4.ClockStatusName) && !kIsEmptyString(self.model.TimeData4.NamingStatusName)) {
                        UIButton *btn2 = [UIButton buttonWithType:UIButtonTypeCustom];
                        [btn2 setTitle:self.model.TimeData4.NamingStatusName forState:0];
                        btn2.titleLabel.font = [UIFont boldSystemFontOfSize:10.f];
                        btn2.titleLabel.textAlignment = NSTextAlignmentCenter;
                        [btn2 setBackgroundColor:kWhiteColor];
                        [item.view addSubview:btn2];
                        [btn2 mas_makeConstraints:^(MASConstraintMaker *make) {
                            make.width.mas_equalTo(35);
                            make.height.mas_equalTo(25);
                            make.center.mas_equalTo(item.view);
                        }];
                        if ([self.model.TimeData4.NamingStatusName isEqualToString:@"请假"]) {
                            [btn2 setTitleColor:kFF8700Color forState:UIControlStateNormal];
                            btn2.layer.borderWidth = 0.5f;
                            btn2.layer.borderColor = kFF8700Color.CGColor;
                        }else if ([self.model.TimeData4.NamingStatusName isEqualToString:@"已到"]){
                            [btn2 setTitleColor:k1168E6Color forState:UIControlStateNormal];
                            btn2.layer.borderWidth = 0.5f;
                            btn2.layer.borderColor = k1168E6Color.CGColor;
                            
                        }else if ([self.model.TimeData4.NamingStatusName isEqualToString:@"未到"]){
                            [btn2 setTitleColor:kRedColor forState:UIControlStateNormal];
                            btn2.layer.borderWidth = 0.5f;
                            btn2.layer.borderColor = kRedColor.CGColor;
                            
                        }
                        
                    }
                }
            }
            
            //row=4
            if (indexPath.row == 4) {
                if (self.model.TimeData5 != nil) {
                    //都有的情况
                    if (!kIsEmptyString(self.model.TimeData5.ClockStatusName) && !kIsEmptyString(self.model.TimeData5.NamingStatusName)) {
                        UIButton *btn1 = [UIButton buttonWithType:UIButtonTypeCustom];
                        [btn1 setTitle:self.model.TimeData5.ClockStatusName forState:0];
                        btn1.titleLabel.font = [UIFont boldSystemFontOfSize:10.f];
                        btn1.titleLabel.textAlignment = NSTextAlignmentCenter;
                        [btn1 setBackgroundColor:kWhiteColor];
                        [item.view addSubview:btn1];
                        [btn1 mas_makeConstraints:^(MASConstraintMaker *make) {
                            make.left.mas_equalTo(12);
                            make.width.mas_equalTo(35);
                            make.height.mas_equalTo(25);
                            make.centerY.mas_equalTo(item.view);
                        }];
                        
                        if ([self.model.TimeData5.ClockStatusName isEqualToString:@"请假"]) {
                            [btn1 setTitleColor:kWhiteColor forState:UIControlStateNormal];
                            [btn1 setBackgroundColor:kFF8700Color];
                            //请假
                            btn1.tag = 5;
                            [btn1 addTarget:self action:@selector(btn1ApplyAction:) forControlEvents:UIControlEventTouchUpInside];
                        }else if ([self.model.TimeData5.ClockStatusName isEqualToString:@"正常"]){
                            [btn1 setTitleColor:k1168E6Color forState:UIControlStateNormal];
                            btn1.layer.borderWidth = 0.5f;
                            btn1.layer.borderColor = k1168E6Color.CGColor;
                            
                        }else if ([self.model.TimeData5.ClockStatusName isEqualToString:@"缺卡"]){
                            [btn1 setTitleColor:kRedColor forState:UIControlStateNormal];
                            btn1.layer.borderWidth = 0.5f;
                            btn1.layer.borderColor = kRedColor.CGColor;
                        }else if ([self.model.TimeData5.ClockStatusName isEqualToString:@"迟到"] || [self.model.TimeData5.ClockStatusName isEqualToString:@"早退"]){
                            [btn1 setTitleColor:kFF8700Color forState:UIControlStateNormal];
                            btn1.layer.borderWidth = 0.5f;
                            btn1.layer.borderColor = kFF8700Color.CGColor;
                        }
                        
                        UIButton *btn2 = [UIButton buttonWithType:UIButtonTypeCustom];
                        [btn2 setTitle:self.model.TimeData5.NamingStatusName forState:0];
                        btn2.titleLabel.font = [UIFont boldSystemFontOfSize:10.f];
                        btn2.titleLabel.textAlignment = NSTextAlignmentCenter;
                        [btn2 setBackgroundColor:kWhiteColor];
                        [item.view addSubview:btn2];
                        [btn2 mas_makeConstraints:^(MASConstraintMaker *make) {
                            make.right.mas_equalTo(-12);
                            make.width.mas_equalTo(35);
                            make.height.mas_equalTo(25);
                            make.centerY.mas_equalTo(item.view);
                        }];
                        if ([self.model.TimeData5.NamingStatusName isEqualToString:@"请假"]) {
                            [btn2 setTitleColor:kFF8700Color forState:UIControlStateNormal];
                            btn2.layer.borderWidth = 0.5f;
                            btn2.layer.borderColor = kFF8700Color.CGColor;
                        }else if ([self.model.TimeData5.NamingStatusName isEqualToString:@"已到"]){
                            [btn2 setTitleColor:k1168E6Color forState:UIControlStateNormal];
                            btn2.layer.borderWidth = 0.5f;
                            btn2.layer.borderColor = k1168E6Color.CGColor;
                            
                        }else if ([self.model.TimeData5.NamingStatusName isEqualToString:@"未到"]){
                            [btn2 setTitleColor:kRedColor forState:UIControlStateNormal];
                            btn2.layer.borderWidth = 0.5f;
                            btn2.layer.borderColor = kRedColor.CGColor;
                            
                        }
                    }
                    
                    //有ClockStatusName NamingStatusName没有
                    if (!kIsEmptyString(self.model.TimeData5.ClockStatusName) && kIsEmptyString(self.model.TimeData5.NamingStatusName)) {
                        
                        UIButton *btn1 = [UIButton buttonWithType:UIButtonTypeCustom];
                        [btn1 setTitle:self.model.TimeData5.ClockStatusName forState:0];
                        btn1.titleLabel.font = [UIFont boldSystemFontOfSize:10.f];
                        btn1.titleLabel.textAlignment = NSTextAlignmentCenter;
                        [btn1 setBackgroundColor:kWhiteColor];
                        [item.view addSubview:btn1];
                        [btn1 mas_makeConstraints:^(MASConstraintMaker *make) {
                            make.width.mas_equalTo(35);
                            make.height.mas_equalTo(25);
                            make.center.mas_equalTo(item.view);
                        }];
                        
                        if ([self.model.TimeData5.ClockStatusName isEqualToString:@"请假"]) {
                            [btn1 setTitleColor:kWhiteColor forState:UIControlStateNormal];
                            [btn1 setBackgroundColor:kFF8700Color];
                            //请假
                            btn1.tag = 5;
                            [btn1 addTarget:self action:@selector(btn1ApplyAction:) forControlEvents:UIControlEventTouchUpInside];
                        }else if ([self.model.TimeData5.ClockStatusName isEqualToString:@"正常"]){
                            [btn1 setTitleColor:k1168E6Color forState:UIControlStateNormal];
                            btn1.layer.borderWidth = 0.5f;
                            btn1.layer.borderColor = k1168E6Color.CGColor;
                            
                        }else if ([self.model.TimeData5.ClockStatusName isEqualToString:@"缺卡"]){
                            [btn1 setTitleColor:kRedColor forState:UIControlStateNormal];
                            btn1.layer.borderWidth = 0.5f;
                            btn1.layer.borderColor = kRedColor.CGColor;
                        }else if ([self.model.TimeData5.ClockStatusName isEqualToString:@"迟到"] || [self.model.TimeData5.ClockStatusName isEqualToString:@"早退"]){
                            [btn1 setTitleColor:kFF8700Color forState:UIControlStateNormal];
                            btn1.layer.borderWidth = 0.5f;
                            btn1.layer.borderColor = kFF8700Color.CGColor;
                        }
                        
                    }
                    
                    //没有ClockStatusName NamingStatusName有
                    if (kIsEmptyString(self.model.TimeData5.ClockStatusName) && !kIsEmptyString(self.model.TimeData5.NamingStatusName)) {
                        UIButton *btn2 = [UIButton buttonWithType:UIButtonTypeCustom];
                        [btn2 setTitle:self.model.TimeData5.NamingStatusName forState:0];
                        btn2.titleLabel.font = [UIFont boldSystemFontOfSize:10.f];
                        btn2.titleLabel.textAlignment = NSTextAlignmentCenter;
                        [btn2 setBackgroundColor:kWhiteColor];
                        [item.view addSubview:btn2];
                        [btn2 mas_makeConstraints:^(MASConstraintMaker *make) {
                            make.width.mas_equalTo(35);
                            make.height.mas_equalTo(25);
                            make.center.mas_equalTo(item.view);
                        }];
                        if ([self.model.TimeData5.NamingStatusName isEqualToString:@"请假"]) {
                            [btn2 setTitleColor:kFF8700Color forState:UIControlStateNormal];
                            btn2.layer.borderWidth = 0.5f;
                            btn2.layer.borderColor = kFF8700Color.CGColor;
                        }else if ([self.model.TimeData5.NamingStatusName isEqualToString:@"已到"]){
                            [btn2 setTitleColor:k1168E6Color forState:UIControlStateNormal];
                            btn2.layer.borderWidth = 0.5f;
                            btn2.layer.borderColor = k1168E6Color.CGColor;
                            
                        }else if ([self.model.TimeData5.NamingStatusName isEqualToString:@"未到"]){
                            [btn2 setTitleColor:kRedColor forState:UIControlStateNormal];
                            btn2.layer.borderWidth = 0.5f;
                            btn2.layer.borderColor = kRedColor.CGColor;
                            
                        }
                        
                    }
                }
            }
            
            //row=5
            if (indexPath.row == 5) {
                if (self.model.TimeData6 != nil) {
                    //都有的情况
                    if (!kIsEmptyString(self.model.TimeData6.ClockStatusName) && !kIsEmptyString(self.model.TimeData6.NamingStatusName)) {
                        UIButton *btn1 = [UIButton buttonWithType:UIButtonTypeCustom];
                        [btn1 setTitle:self.model.TimeData6.ClockStatusName forState:0];
                        btn1.titleLabel.font = [UIFont boldSystemFontOfSize:10.f];
                        btn1.titleLabel.textAlignment = NSTextAlignmentCenter;
                        [btn1 setBackgroundColor:kWhiteColor];
                        [item.view addSubview:btn1];
                        [btn1 mas_makeConstraints:^(MASConstraintMaker *make) {
                            make.left.mas_equalTo(12);
                            make.width.mas_equalTo(35);
                            make.height.mas_equalTo(25);
                            make.centerY.mas_equalTo(item.view);
                        }];
                        
                        if ([self.model.TimeData6.ClockStatusName isEqualToString:@"请假"]) {
                            [btn1 setTitleColor:kWhiteColor forState:UIControlStateNormal];
                            [btn1 setBackgroundColor:kFF8700Color];
                            //请假
                            btn1.tag = 6;
                            [btn1 addTarget:self action:@selector(btn1ApplyAction:) forControlEvents:UIControlEventTouchUpInside];
                        }else if ([self.model.TimeData6.ClockStatusName isEqualToString:@"正常"]){
                            [btn1 setTitleColor:k1168E6Color forState:UIControlStateNormal];
                            btn1.layer.borderWidth = 0.5f;
                            btn1.layer.borderColor = k1168E6Color.CGColor;
                            
                        }else if ([self.model.TimeData6.ClockStatusName isEqualToString:@"缺卡"]){
                            [btn1 setTitleColor:kRedColor forState:UIControlStateNormal];
                            btn1.layer.borderWidth = 0.5f;
                            btn1.layer.borderColor = kRedColor.CGColor;
                        }else if ([self.model.TimeData6.ClockStatusName isEqualToString:@"迟到"] || [self.model.TimeData6.ClockStatusName isEqualToString:@"早退"]){
                            [btn1 setTitleColor:kFF8700Color forState:UIControlStateNormal];
                            btn1.layer.borderWidth = 0.5f;
                            btn1.layer.borderColor = kFF8700Color.CGColor;
                        }
                        
                        UIButton *btn2 = [UIButton buttonWithType:UIButtonTypeCustom];
                        [btn2 setTitle:self.model.TimeData6.NamingStatusName forState:0];
                        btn2.titleLabel.font = [UIFont boldSystemFontOfSize:10.f];
                        btn2.titleLabel.textAlignment = NSTextAlignmentCenter;
                        [btn2 setBackgroundColor:kWhiteColor];
                        [item.view addSubview:btn2];
                        [btn2 mas_makeConstraints:^(MASConstraintMaker *make) {
                            make.right.mas_equalTo(-12);
                            make.width.mas_equalTo(35);
                            make.height.mas_equalTo(25);
                            make.centerY.mas_equalTo(item.view);
                        }];
                        if ([self.model.TimeData6.NamingStatusName isEqualToString:@"请假"]) {
                            [btn2 setTitleColor:kFF8700Color forState:UIControlStateNormal];
                            btn2.layer.borderWidth = 0.5f;
                            btn2.layer.borderColor = kFF8700Color.CGColor;
                        }else if ([self.model.TimeData6.NamingStatusName isEqualToString:@"已到"]){
                            [btn2 setTitleColor:k1168E6Color forState:UIControlStateNormal];
                            btn2.layer.borderWidth = 0.5f;
                            btn2.layer.borderColor = k1168E6Color.CGColor;
                            
                        }else if ([self.model.TimeData6.NamingStatusName isEqualToString:@"未到"]){
                            [btn2 setTitleColor:kRedColor forState:UIControlStateNormal];
                            btn2.layer.borderWidth = 0.5f;
                            btn2.layer.borderColor = kRedColor.CGColor;
                            
                        }
                    }
                    
                    //有ClockStatusName NamingStatusName没有
                    if (!kIsEmptyString(self.model.TimeData6.ClockStatusName) && kIsEmptyString(self.model.TimeData6.NamingStatusName)) {
                        
                        UIButton *btn1 = [UIButton buttonWithType:UIButtonTypeCustom];
                        [btn1 setTitle:self.model.TimeData6.ClockStatusName forState:0];
                        btn1.titleLabel.font = [UIFont boldSystemFontOfSize:10.f];
                        btn1.titleLabel.textAlignment = NSTextAlignmentCenter;
                        [btn1 setBackgroundColor:kWhiteColor];
                        [item.view addSubview:btn1];
                        [btn1 mas_makeConstraints:^(MASConstraintMaker *make) {
                            make.width.mas_equalTo(35);
                            make.height.mas_equalTo(25);
                            make.center.mas_equalTo(item.view);
                        }];
                        
                        if ([self.model.TimeData6.ClockStatusName isEqualToString:@"请假"]) {
                            [btn1 setTitleColor:kWhiteColor forState:UIControlStateNormal];
                            [btn1 setBackgroundColor:kFF8700Color];
                            //请假
                             btn1.tag = 6;
                            [btn1 addTarget:self action:@selector(btn1ApplyAction:) forControlEvents:UIControlEventTouchUpInside];
                        }else if ([self.model.TimeData6.ClockStatusName isEqualToString:@"正常"]){
                            [btn1 setTitleColor:k1168E6Color forState:UIControlStateNormal];
                            btn1.layer.borderWidth = 0.5f;
                            btn1.layer.borderColor = k1168E6Color.CGColor;
                            
                        }else if ([self.model.TimeData6.ClockStatusName isEqualToString:@"缺卡"]){
                            [btn1 setTitleColor:kRedColor forState:UIControlStateNormal];
                            btn1.layer.borderWidth = 0.5f;
                            btn1.layer.borderColor = kRedColor.CGColor;
                        }else if ([self.model.TimeData6.ClockStatusName isEqualToString:@"迟到"] || [self.model.TimeData6.ClockStatusName isEqualToString:@"早退"]){
                            [btn1 setTitleColor:kFF8700Color forState:UIControlStateNormal];
                            btn1.layer.borderWidth = 0.5f;
                            btn1.layer.borderColor = kFF8700Color.CGColor;
                        }
                        
                    }
                    
                    //没有ClockStatusName NamingStatusName有
                    if (kIsEmptyString(self.model.TimeData6.ClockStatusName) && !kIsEmptyString(self.model.TimeData6.NamingStatusName)) {
                        UIButton *btn2 = [UIButton buttonWithType:UIButtonTypeCustom];
                        [btn2 setTitle:self.model.TimeData6.NamingStatusName forState:0];
                        btn2.titleLabel.font = [UIFont boldSystemFontOfSize:10.f];
                        btn2.titleLabel.textAlignment = NSTextAlignmentCenter;
                        [btn2 setBackgroundColor:kWhiteColor];
                        [item.view addSubview:btn2];
                        [btn2 mas_makeConstraints:^(MASConstraintMaker *make) {
                            make.width.mas_equalTo(35);
                            make.height.mas_equalTo(25);
                            make.center.mas_equalTo(item.view);
                        }];
                        if ([self.model.TimeData6.NamingStatusName isEqualToString:@"请假"]) {
                            [btn2 setTitleColor:kFF8700Color forState:UIControlStateNormal];
                            btn2.layer.borderWidth = 0.5f;
                            btn2.layer.borderColor = kFF8700Color.CGColor;
                        }else if ([self.model.TimeData6.NamingStatusName isEqualToString:@"已到"]){
                            [btn2 setTitleColor:k1168E6Color forState:UIControlStateNormal];
                            btn2.layer.borderWidth = 0.5f;
                            btn2.layer.borderColor = k1168E6Color.CGColor;
                            
                        }else if ([self.model.TimeData6.NamingStatusName isEqualToString:@"未到"]){
                            [btn2 setTitleColor:kRedColor forState:UIControlStateNormal];
                            btn2.layer.borderWidth = 0.5f;
                            btn2.layer.borderColor = kRedColor.CGColor;
                            
                        }
                        
                    }
                }
            }
        }else{
            UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
            [btn setTitle:@"详情" forState:0];
            btn.titleLabel.font = [UIFont systemFontOfSize:12.0f];
            btn.titleLabel.textAlignment = NSTextAlignmentCenter;
            [btn setTitleColor:kWhiteColor forState:0];
            [btn setBackgroundColor:k0C80EBColor];
            [item.view addSubview:btn];
            btn.layer.cornerRadius = 5.0f;
            btn.clipsToBounds = true;
            [btn addTarget:self action:@selector(detailAction:) forControlEvents:UIControlEventTouchUpInside];
            [btn mas_makeConstraints:^(MASConstraintMaker *make) {
                make.width.mas_equalTo(60);
                make.height.mas_equalTo(30);
                make.center.mas_equalTo(item.view);
            }];
        }
    }
    return item;
}

#pragma mark -- UICollectionViewDelegate

#pragma mark -- UIScrollDelegate
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView{
    self.isNoti = false;
}
- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
    if (self.isNoti == false) {
        [[NSNotificationCenter defaultCenter] postNotificationName:Noti_ScrollMove object:self userInfo:@{@"contentOffsetX":@(scrollView.contentOffset.x)}];
    }
    self.isNoti = false;
}
- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate{
    if (self.isNoti == false) {
        [[NSNotificationCenter defaultCenter] postNotificationName:Noti_ScrollMove object:self userInfo:@{@"contentOffsetX":@(scrollView.contentOffset.x)}];
    }
    self.isNoti = false;
}
#pragma mark -- Noti_ScrollMove
- (void)scrollMove:(NSNotification *)noti{
    NSDictionary *info = noti.userInfo;
    float x = [info[@"contentOffsetX"] floatValue];
    if (noti.object != self) {
        self.isNoti = true;
        [self.collectionView setContentOffset:CGPointMake(x, 0) animated:NO];
    }else{
        self.isNoti = false;
    }
}
/**
 请假按钮
 */
- (void)btn1ApplyAction:(UIButton *)sender{
    NSInteger tag = sender.tag;
    //请假id
    NSString *leaveApplyId = nil;
    if (tag == 1) {
        leaveApplyId = self.model.TimeData1.LeaveApplyId;
    }else if (tag == 2){
        leaveApplyId = self.model.TimeData2.LeaveApplyId;
    }else if (tag == 3){
        leaveApplyId = self.model.TimeData3.LeaveApplyId;
    }else if (tag == 4){
        leaveApplyId = self.model.TimeData4.LeaveApplyId;
    }else if (tag == 5){
        leaveApplyId = self.model.TimeData5.LeaveApplyId;
    }else if (tag == 6){
        leaveApplyId = self.model.TimeData6.LeaveApplyId;
    }
    if (self.ruleCellLeaveApplyBlock) {
        self.ruleCellLeaveApplyBlock(leaveApplyId);
    }
}

/**
 详情
 */
- (void)detailAction:(UIButton *)sender{
    if (self.ruleCellBlockOne) {
        self.ruleCellBlockOne(self.model);
    }
}
@end
